import request from '../../router/axios'

//查询可配置产品列表
export const getConfigurableMaterial = params => request({
  url: '/admin/materialbase/getConfigurableMaterial',
  method: 'get',
  params
})

export const getVersion = (factoryId, usages, materialId) => request({ // 查询一个物料有多个版本
  url: '/erp/erpbom/getMaterialVersionNo',
  method: 'get',
  params: {
    factoryId,
    usages,
    materialId
  }
})

export const getErpbomparam = () => request({ // BOM用途查询
  url: '/admin/erpbomparam/list',
  method: 'get'
})

export const getVariantClassData = (isHidden, objectId, tableName) => request({ // 获取某对象id的变式分类属性值
  url: '/admin/sys/class/character/getVariantClassData',
  method: 'get',
  params: {
    isHidden,
    objectId,
    tableName
  }
})

export const getVariantTableClassId = (classId) => request({ // 根据类id查询该类的变式表详情
  url: '/admin/sysclassrelevant/variantTable/getByClassId',
  method: 'get',
  params: {
    classId
  }
})

export const getCharacterConfigureClassId = (classId) => request({ // 根据类id查询该类的分类属性配置详情
  url: '/admin/sysclassrelevant/characterConfigure/getByClassId',
  method: 'get',
  params: {
    classId
  }
})

export const getMatching = (data, factoryId) => request({ // 根据属性与属性值查询物料选配结果
  url: `/admin/materialbase/matching${factoryId?`?factoryId=${factoryId}`:''}`,
  method: 'post',
  data
})

export const getBom = data => request({ // 选配结果-bom查看
  url: '/admin/sysbomcharacterconfigure/getBom',
  method: 'post',
  data
})

export const checkConfigure = (data, classId) => request({ // 校验类属性值是否满足变式表
  url: '/admin/sysclassrelevant/check/configure?classId=' + classId,
  method: 'post',
  data
})

export const getBomListByMaterialId = (factoryId, materialId) => request({ // 根据物料id获取该物料对应的bom列表
  url: '/erp/erpbom/getBomListByMaterialId',
  method: 'get',
  params: {
    factoryId,
    materialId
  }
})

export function getOperator(data) { // 获取运算符
  return request({
    url: '/admin/commonconfig/operator/list',
    method: 'get',
    params: data
  })
}
